package cn.edu.abtu.controller;

import cn.edu.abtu.entity.vo.CourseInfoVo;
import cn.edu.abtu.service.EduCourseService;
import cn.edu.abtu.vo.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/eduservice/course")
public class EduCourseController {

    @Autowired
    private EduCourseService eduCourseService;

    @PostMapping("/addCourseInfo")
    public ResponseData addCourseInfo(@RequestBody CourseInfoVo courseInfoVo){
        return eduCourseService.addCourseInfo(courseInfoVo);
    }

    @DeleteMapping("/deleteCourse/{courseId}")
    public ResponseData deleteCourse(@PathVariable String courseId){
        return eduCourseService.deleteCourse(courseId);
    }

    @GetMapping("/getCourseInfo/{courseId}")
    public ResponseData getCourseInfo(@PathVariable String courseId){
        return eduCourseService.getCourseInfo(courseId);
    }

    @GetMapping("/getCoursePublishInfo/{courseId}")
    public ResponseData getCoursePublishInfo(@PathVariable String courseId){
        return eduCourseService.getCoursePublishInfo(courseId);
    }

    @GetMapping("/getCoursePage")
    public ResponseData getCoursePage(Integer pageNum,Integer pageSize,String courseName,String status){
        return eduCourseService.getCoursePage(pageNum,pageSize,courseName,status);
    }

    @PutMapping("/updateCourseInfo")
    public ResponseData updateCourseInfo(@RequestBody CourseInfoVo courseInfoVo){
        return eduCourseService.updateCourseInfo(courseInfoVo);
    }

    @PutMapping("/publishCourse/{courseId}")
    public ResponseData publishCourse(@PathVariable String courseId){
        return eduCourseService.publishCourse(courseId);
    }
}

